<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="canvas-blending-helpers.js"></script>
<script>
async_test(function(t) {
    function drawElement(context, i) {
        if (i >= blendModes.length) {
            t.done();
            return;
        }

        context.clearRect(0, 0, 10, 10);
        context.save();
        drawBackdropColorPatternInContext(context, function() {
            context.globalCompositeOperation = blendModes[i];

            drawSourceColorPatternInContext(context, function() {
                t.step(function () {
                    checkBlendModeResult(i, context, 5);
                });
                context.restore();
                drawElement(context, i + 1);
            });
        });
    }

    var canvas = document.createElement('canvas');
    canvas.width = canvas.height = 10;
    context = canvas.getContext('2d');
    drawElement(context, 0);

}, 'Series of tests to ensure correct results on applying different blend modes when drawing a pattern on top of another.');
</script>
